package com.dadi.kotlinretrofit

import com.dadi.kotlinretrofit.model.MovieResult
import com.dadi.kotlinretrofit.utils.Constants
import retrofit2.Call
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.Query

/**
 *  author: 韦敏敏
 *  date: 2020/1/5 0005
 */
interface ApiInterface {
    fun getMovies(@Query("api_key") key: String,
                  @Query("page") page: Int): Call<MovieResult>
    companion object Factory {
        fun create():ApiInterface {
            val retrofit = Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl(Constants.BASE_URL)
                .build()
            return retrofit.create(ApiInterface::class.java)
        }
    }
}